package cn.demo.cm.domain;

import lombok.Data;
import lombok.EqualsAndHashCode;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.core.constant.SqlOperator;
import com.mybatisflex.core.query.SqlOperators;
import cn.demo.common.mybatisFlex.MyInsertListener;
import cn.demo.common.mybatisFlex.MyUpdateListener;
import cn.demo.common.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import cn.demo.common.core.domain.TreeEntity;
/**
 * 栏目管理对象 cm_category
 *
 * @author xtjun
 * @date 2024-06-04
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Table(value = "cm_category",onInsert = MyInsertListener.class,onUpdate = MyUpdateListener.class)
public class CmCategory extends TreeEntity {
    private static final long serialVersionUID = 1L;

    @Id
    @Schema(description = "id")
    private String id;

    @Excel(name = "栏目名称")
    @Schema(description = "栏目名称")
    private String categoryTitle;

    @Excel(name = "缩略图")
    @Schema(description = "缩略图")
    private String categoryImg;

    @Excel(name = "关键字")
    @Schema(description = "关键字")
    private String categoryKeyword;

    @Excel(name = "栏目类型", dictType = "cm_category_type")
    @Schema(description = "栏目类型(字典:cm_category_type)")
    private Integer categoryType;

    @Excel(name = "排序")
    @Schema(description = "排序")
    private Long sort;

    @Excel(name = "是否仅管理员可见", dictType = "sys_yes_no")
    @Schema(description = "是否仅管理员可见(字典:sys_yes_no)")
    private Integer isAdmin;

    // 自定义字段的 SQL 操作符
    @JsonIgnore
    public static final SqlOperators operators = new SqlOperators() {{
        set(CmCategory::getParentId, SqlOperator.EQUALS);
        set(CmCategory::getCategoryTitle, SqlOperator.LIKE);
        set(CmCategory::getCategoryKeyword, SqlOperator.EQUALS);
        set(CmCategory::getCategoryType, SqlOperator.EQUALS);
        set(CmCategory::getSort, SqlOperator.EQUALS);
        set(CmCategory::getIsAdmin, SqlOperator.EQUALS);
    }};
}
